//
// Created by 123 on 2025/1/8.
//
#include "deque"
#include "vector"
#include "algorithm"
#include "iostream"
using namespace std;

class Player{
public:
    string name;
    int score;
public:
    Player(string name,int score){
        this->name = name;
        this->score=score;
    }
};

void initPlayers(vector<Player>& v){
    string nameSeed = "ABCDE";
    for (int i = 0; i < 5; ++i) {
        string name="player:";
        name+=nameSeed[i];
        int score=0;
        Player p(name,score);
        v.push_back(p);
    }
}

void printDeque(deque<int>& d){
    for(deque<int>::const_iterator it=d.begin();it!=d.end();it++){
        cout << *it << " ";
    }
    cout << endl;
}

void showPlayerScore(vector<Player>& v){
    for(vector<Player>::iterator it=v.begin();it!=v.end();it++){
        cout << "name=" << it->name << " avg score=" << it->score << endl;
    }
}

void setScore(vector<Player>& v){
    //10个评委给5个选手打随机分
    for(vector<Player>::iterator it=v.begin();it != v.end();it++){
        deque<int> d;
        for (int i = 0; i < 10; ++i) {
            int score = rand()%41+60;//60-100
            d.push_back(score);
        }
        //打印打分
        cout << it->name << " score: " ;
        printDeque(d);
        //排序
        sort(d.begin(),d.end());
        //去除最高分最低分
        d.pop_back();
        d.pop_front();
        //取平均分
        int sum = 0;
        for(int s:d){
            sum += s;
        }
        //平均分设置给选手
        it->score = sum/d.size();
    }
}

int main129(){
    srand((unsigned int)time(NULL));

    vector<Player> v;
    initPlayers(v);
    setScore(v);
    showPlayerScore(v);
}